<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>AngularJs的事件绑定</title>
    <script src="../js/angular.min.js" type="text/javascript"></script>
</head>
<body>
    <div ng-app="myapp" ng-controller="myctrl">
        <div>
            数量:<input type="text" name="count" ng-model="count"/><br/>
            价格<input type="text" name="price" ng-model="price"/>
        </div>
        <div>
            总价: <input type="text"name="total"value="{{count*price}}"/>
        </div>
        <div>
            <input type="button" value="归零" ng-click="clearVal()"/>
        </div>
    </div>
    <script type="text/javascript">
        //初始化myapp模型作用域
        var myapp=angular.module("myapp",[]);
        //定义模块的控制器
        //依赖注入,$scope作用域对象,操作当前作用域试图
        myapp.controller("myctrl",["$scope",function ($scope) {
            //对模型进行初始化
            $scope.count=0;
            $scope.price=0;
            $scope.clearVal=function () {
                $scope.count="";
                $scope.price="";
            }
        }]);
    </script>

</body>
</html>